package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.service.NursingGradeService;
import com.zzyl.vo.NursingLevelVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/nursingLevel")
@Api(tags = "护理等级")
public class NursingGradeController extends BaseController{
    @Autowired
    private NursingGradeService nursingGradeService;

    /**
     * 查询所有护理等级
     * @return
     */
    @ApiOperation("查询所有护理等级")
    @GetMapping("/listAll")
    public ResponseResult findAll(){
        List<NursingLevelVo> nursingLevelVoList = nursingGradeService.findAll();
        return success(nursingLevelVoList);
    }

    @ApiOperation("新增护理等级")
    @PostMapping("/insert")
    public ResponseResult add(
            @ApiParam(value = "新增的对象参数",required = true)
            @RequestBody NursingLevelDto nursingLevelDto){
        nursingGradeService.add( nursingLevelDto );
        return success();
    }

    @ApiOperation("分页查询")
    @GetMapping("/listByPage")
    public ResponseResult listPage(
            @ApiParam(value = "页码",required = true) Integer pageNum,
            @ApiParam(value = "每页大小",required = true) Integer pageSize,
            @ApiParam(value = "护理等级名称",required = true) String name,
            @ApiParam(value = "护理等级状态",required = true) Integer status
    ){
        PageResponse<NursingLevelVo> nursingLevelVoList = nursingGradeService.listPage(pageNum,pageSize,name,status);
         return success(nursingLevelVoList);
    }
}
